﻿@{
    ViewBag.Title = "Checkout";
}
<div class="Center">
<div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">Tài khoản của tôi</a>
            </li>
            <li>
                <span>Thanh toán</span>
            </li>
        </ul>
    </div>
        <div id="CartContainer" class="Block Moveable Panel">

        <div class="BlockContent">
            @if (ViewBag.proList != null)
            {
                <form action="/Account/cartHandler" method="post">
                    <div>
                        <div>

                            <table class="CartContents" cellspacing="0" rules="rows" border="1" id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; border-collapse: collapse;">
                                <tbody>
                                    <tr>
                                        <th align="left" scope="col">Sản phẩm
                                        </th>                                        
                                        <th scope="col">Số lượng
                                        </th>
                                        <th align="right" scope="col">Giá
                                        </th>
                                        <th align="right" scope="col">Tổng
                                        </th>
                                        
                                    </tr>
                                    @{var subTotal = 0;}
                                    @foreach (var pro in ViewBag.proList)
                                    {
                                        <tr>
                                            <td align="left">
                                                <a href="javascript:;" onclick="javascript:viewProduct(@pro.ID)">
                                                    <strong>@pro.name</strong></a>
                                                <div style="font-style: italic;"></div>
                                                <br>                                                
                                                <span class="hidden">0</span>
                                            </td>                                            
                                            <td align="center" style="width: 70px;">
                                                <input name="quantity @pro.ID" type="text" value="@ViewBag.cart[pro.ID]" maxlength="3" id="quantity @pro.ID" class="NormalTextBox" style="width: 45px;">
                                                <input type="hidden" name="ctl00$cphMain$ctl00$ctl01$ctl00$grvList$ctl02$hdId" id="cphMain_ctl00_ctl01_ctl00_grvList_hdId_0" value="2143943">
                                            </td>
                                            <td align="right" style="width: 80px;">                                                
                                                @{var price = Convert.ToInt32(pro.price);
                                                 }
                                                @if(pro.promotion_ID > 0)
                                                {
                                                 <strike>@Convert.ToInt32(pro.price) VND / thùng</strike>
                                                <br/>
                                                    price = Convert.ToInt32(pro.price / 100 * (100 - pro.Promotion.rate));
                                                <span>@price VND / thùng</span>                                                 
                                                }
                                                else
                                                {
                                                <span>@price VND / thùng</span>
                                                }
                                            </td>
                                            <td align="right" style="width: 90px;">
                                                @{int priceTotal = ViewBag.cart[pro.ID] * price;
                                                  subTotal += priceTotal;}
                                                <b>@priceTotal VND</b>
                                            </td>
                                            
                                        </tr>
                                    }
                                    <tr>
                                        <td align="right" colspan="4">
                                            <div class="SubTotal">
                                                Thành tiền:
                                            </div>

                                            <div class="SubTotal">
                                                Thuế (10%):
                                            </div>                                            
                                            <div class="SubTotal">
                                                Tổng tiền thanh toán:
                                            </div>
                                        </td>
                                        <td align="right">
                                            <div>
                                                <em class="ProductPrice">@subTotal VND</em>
                                            </div>
                                            @{var tax = subTotal * 10 / 100;}
                                            <div>
                                                <em id="promotionPrice" class="ProductPrice">@tax VND</em>
                                            </div>               
                                            @{var total = subTotal + tax;}                             
                                            <div>
                                                <em id="grandTotal" class="ProductPrice">@total VND</em>
                                            </div>
                                        </td>
                                        <td>&nbsp;</td>
                                    </tr>
                                </tbody>
                            </table>

                        </div>

                    </div>

                    <div class="Clear">
                        <div class="FloatRight">
                            <input type="submit" name="Action" value="Cập nhật số lượng" id="Action">
                            <input type="submit" name="Action" value="Xóa giỏ hàng" onclick="javascript: return confirm('Xóa toàn bộ thông tin về giỏ hàng của bạn ?');" id="Action2">
                            <input type="submit" name="Action" value="Đặt mua &amp; Thanh toán" id="Action3">
                        </div>
                    </div>

                    <div class="Clear">
                    </div>
                </form>
            }
            else
            {        
                <div>
                    Chưa có sản phẩm nào trong giỏ hàng của bạn!
                
                </div>

                <div class="Clear">
                </div>
            }
        </div>
    </div>        

    </div>